<?php 
/**
 * Helps to show location path.
 * 
* @author Oliver Leisalu, Inditel Meedia
* @package DomFg
* @subpackage Cells
*/
class DomFgLocationPath extends DomFgComponent {
	
	protected $path = array();
	
	protected $nameMaxLength = 20;
	
	public function __construct( array $path = array() ) {
		$this->path( $path );
	}
	
	/**
	 * Add path elements as two dimensional array. 
	 * Inner Array may consist of these keys:
	 * name - name that will be displayed
	 * link - user is sent to there if it is clicked
	 *
	 * NB! If path array is empty, location path element is not shown!
	 * 
	 * @param array $path
	 * @return unknown
	 */
	public function path( array $path ) {
		$this->path = $path;
		return $this;
	}	
	/**
	 * Shortens element name if its longer than given value
	 *
	 * @param Int $value
	 */
	public function nameMaxLength( $value ) {
		$this->nameMaxLength = (int)$value;
	}
	
	public function render() {
		if( empty($this->path) )
			return ''; 
		$renderer = $this->getRenderer();
		$renderer->assign('cell', $this );
		return $renderer->fetch('Cells/LocationPath.html');
	}
	

}
?>